using SqlSugar;

namespace ZR.Model.Models.ProductionControl
{
    /// <summary>
    /// PLC配置表
    /// </summary>
    [SugarTable("plc_config")]
    public class PlcConfig : BaseEntity
    {
        private bool is_enabled;


        public PlcConfig() {

            _Operate = new AntdUI.CellLink[] {
                        new AntdUI.CellButton("save","保存",AntdUI.TTypeMini.Primary),
                        new AntdUI.CellButton("del", "删除",AntdUI.TTypeMini.Error)
                    };

        }


        /// <summary>
        /// Id
        /// </summary>
        [SugarColumn(ColumnName = "Id")]
        public int Id { get; set; }

        /// <summary>
        /// 产线代号
        /// </summary>
        [SugarColumn(ColumnName = "production_line_code")]
        public string ProductionLineCode { get; set; }

        /// <summary>
        /// 工位代号
        /// </summary>
        [SugarColumn(ColumnName = "workstation_code")]
        public string WorkstationCode { get; set; }

        public string Remark { get; set; } = string.Empty;

        /// <summary>
        /// PLC类型
        /// </summary>
        [SugarColumn(ColumnName = "plc_type")]
        public string PlcType { get; set; } = string.Empty;

        /// <summary>
        /// PLC地址
        /// </summary>
        [SugarColumn(ColumnName = "plc_address")]
        public string PlcAddress { get; set; } = string.Empty;

        /// <summary>
        /// CPU类型
        /// </summary>
        [SugarColumn(ColumnName = "cpu_type")]
        public string CpuType { get; set; } = "1200";

        /// <summary>
        /// 插槽号
        /// </summary>
        [SugarColumn(ColumnName = "slot_number")]
        public int SlotNumber { get; set; } = 1;

        /// <summary>
        /// 机架号
        /// </summary>
        [SugarColumn(ColumnName = "rack_number")]
        public int RackNumber { get; set; } = 0;

        /// <summary>
        /// 创建时间
        /// </summary>
        [SugarColumn(ColumnName = "creation_time")]
        public DateTime? CreationTime { get; set; }

        /// <summary>
        /// 创建人
        /// </summary>
        [SugarColumn(ColumnName = "creator_name")]
        public string CreatorName { get; set; } = string.Empty;




        /// <summary>
        /// 是否启用
        /// </summary>
        [SugarColumn(ColumnName = "is_enabled")]
        public bool IsEnabled { get => is_enabled; 
            set 
            {
                is_enabled = value;
                OnPropertyChanged("IsEnabled");
            } 
        }

        public bool AgvEnable { 
            get => agvEnable;
            set {

                agvEnable = value;
                OnPropertyChanged("AgvEnable");
            } 
        }



        AntdUI.CellLink[] _Operate;
        private bool agvEnable;

        [SugarColumn(IsIgnore =true)]
        public AntdUI.CellLink[] Operate
        {
            get => _Operate;
            set
            {
                _Operate = value;
                OnPropertyChanged("Operate");
            }
        }
    }
}